package com.hclc.entity.model.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * 是否是超级管理员{YES,1,是;NO,0,否}
 * @author yurj
 * @mail 1638234804@qq.com
 * @version 1.0
 * @date 2020/8/23 14:11
 */
public enum AdminStatusEnum implements IEnum<Integer> {


        YES(1, "是"),


        NO(0, "否");



        @JsonValue
        @EnumValue
        private final int code;


        private final String desc;
        AdminStatusEnum(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }
        @Override
        public Integer getValue() {
            return code;
        }
        public String getDesc(){return desc;}
        public static AdminStatusEnum find( String desc ) throws IllegalArgumentException{
            for (AdminStatusEnum model : AdminStatusEnum.values()) {
                if (model.getDesc().equals(desc)) {
                    return model;
                }
            }
            throw new IllegalArgumentException();
        }
        @JsonCreator
        public static AdminStatusEnum find( int code ) throws IllegalArgumentException{
            for (AdminStatusEnum model : AdminStatusEnum.values()) {
                if (model.getValue() == code) {
                    return model;
                }
            }
            throw new IllegalArgumentException();
        }
    }
